<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cell {
    background: #fff;
  }
  .weui-cells__title {
    text-align: left;
  }
  .oitem {
    padding: 3px;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  .weui-label {
    text-align: left;
  }
</style>
<template>
  <div class="oitem">
    <input    type="hidden" :name="appand(itemNo,'guid')"  :value="product.guid">
    <input    type="hidden" :name="appand(itemNo,'productid')"  :value="product.productid">
    <input    type="hidden" :name="appand(itemNo,'specguid')"  :value="product.specguid">
    <input    type="hidden" :name="appand(itemNo,'stockunit')"  :value="product.stockunit">
    <input    type="hidden" :name="appand(itemNo,'stockunitid')"  :value="product.stockunitid">
    <div class="weui-cells__title">货品明细 {{itemNo + 1}}</div>
    <div class="weui-cell fir">
      <div class="weui-cell__hd"><label class="weui-label">产品</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" name="" readonly="true" :value="product.productName">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">规格</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" name="" readonly="true" :value="product.specName">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">数量{{product.stockunit ? `(${product.stockunit})` : ''}}</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input weight" type="number" :name="appand(itemNo,'weight')" placeholder="请输入数量">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label for="" class="weui-label">库间</label></div>
      <div class="weui-cell__bd">
        <select class="weui-select"  :name="appand(itemNo,'shguid')"   >
          <option selected=""  v-for="(item, index) in storehouserooms" :key="item.guid" :value="item.guid">{{item.name}}</option>
        </select>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'OutStoreRmItem',
  data () {
    return {
      storehouserooms: []
    }
  },
  props: [
    'itemNo',
    'product',
    'strmid',
  ],
  computed: {
  },
  watch: {
    'strmid': function (val) {
      this.getStorehouseroom();
    }
  },
  mounted() {
    this.getStorehouseroom();
  },
  methods: {
    appand:function (index,key){
      return "items[" + index + "]." + key;
    },
    getStorehouseroom: function(guid, type) {
      if (!this.checkNull(this.strmid)) return;
      this.axios({
        method: 'get',
        url: '/produce/StoreHouse!getHousesByType.action',
        params: {srguid: this.strmid, type: this.product.type}
      }).then((response) => {
        if (response.data != 'error') {
          let data = response.data;
          this.storehouserooms= data.houses;
        } else {
          this.toastError("系统错误");
        }

      })
    }
  }
}
</script>
